<?php
    include_once '../connection/databaseHandler.php';
    include_once '../connection/sessionHandler.php';
    $database = new DatabaseHandler();
    $session = new SessionHandler();

    $photo_id = $_GET['photo-id'];
    $username = $session->username;
    $img_location_new = "./res/upload/".$photo_id;

    $query = "UPDATE  $database->t_user
                SET
                    img_location='$img_location_new'
                WHERE
                    username='$username' ";
    if ($database->execQuery($query)) {
        $query="SELECT * FROM ".$database->t_user." WHERE username='".$username."' ";
        $result = $database->execQuery($query);
        $result = mysql_fetch_array($result);
        $session->setSession($result);
        
        header("location:../profile.php");
    }
    else {
        die();
    }
?>
